﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Diagnostics;

namespace Auction_Boxing_2
{

    public class StateHit : State
    {
        GameTimer HitTimer;
        float Wait = 10;
        float Interval = 1000;

        Item item;
        float timer = 1f;

        int direction;
        int vertical_hit;
        float strength;

        /// <summary>
        /// When a player gets hit, they enter the StateHit.
        /// </summary>
        /// <param name="state"></param> 
        /// <param name="item"></param> 
        /// <param name="direction"></param> The direction where they were hit from.
        public StateHit(State state, Item item, DirectionType direction, int vertical_hit, float strength)
        {
            StateName = "hit";
            this.ATextures = state.StatePlayer.ATextures;

            HitTimer = new GameTimer(Wait, Interval);

            this.strength = strength;
            this.vertical_hit = vertical_hit;
            if (direction == DirectionType.Left)
                this.direction = 1;
            else
                this.direction = -1;
            LoadState(state.StatePlayer, ATextures);

            HitTimer.Start();

            this.item = item;
            timer = item.stun;
        }

        public override void LoadState(BoxingPlayer player, Dictionary<string, Animation> ATextures)
        {
            this.StatePlayer = player;
            this.PlayerAnimation = ATextures[StateName];
            StatePlayer.isAttacking = false;
            StatePlayer.isHit = false;

            bool isVert = false;
            /*if (StatePlayer.direction == DirectionType.Left)
                direction = -1;
            if (StatePlayer.direction == DirectionType.Left)
                direction = 1;*/
            

            StatePlayer.particleEngines_hit.Add(new ParticleEngine(
                StatePlayer.hit_textures,
                new Vector2(StatePlayer.position.X, vertical_hit),
                direction, isVert, strength));
            //StatePlayer.Hurtbox = Rectangle.Empty;


        }

        public override void Initialize()
        {

        }

        public override void HandleMovement()
        {


        }

        public override void HandleDirection()
        {


        }

        public override void Update(GameTime gameTime)
        {
            timer -= (float)gameTime.ElapsedGameTime.TotalMilliseconds;

            if (timer <= 0)
                StatePlayer.InternalState = new StateMoving(this);
        }

        public override void HandleState()
        {

        }

        public override void Translate(float x, float y)
        {


        }

        public override void HandleCollision(List<BoxingPlayer> Players)
        {

        }



    }
}
